﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using Provausio.Common.Objects;
using Provausio.Common.Utility.Extensions;
using TrainingManagement.api.Models.BusinessObjects;

namespace TrainingManagement.api.Models.Data.Readers
{
    public class EmployeeDataReader : BusinessOperation<IDataRecord,Employee>
    {
        public override Employee Run(IDataRecord input)
        {
            var emp = new Employee();
            emp.FirstName = input["FirstName"].ToString();
            emp.LastName = input["LastName"].ToString();
            emp.EmployeeId = input["EmployeeID"].DbTo<int>();
            emp.Email = input["Email"].ToString();
            emp.SmsNumber = input["SmsNumber"].ToString();
            emp.ReportsToId = input["ReportsToId"].DbTo<int>();
            emp.IsActive = input["IsActive"].DbTo<bool>();
            emp.DepartmentTreeId = input["DepartmentTreeID"].DbTo<int>();
            return emp;
        }
    }
}